package com.demo.controller;

import java.util.List;

import com.demo.utils.base.WebResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.demo.service.UserService;
import com.demo.domain.entity.User;




/**
 * UserController
 *
 * @author wu
 * @date ${datetime}
 */
@RestController
@RequestMapping("/user")
@Tag(name = "学生信息表管理")
class UserController {
    @Autowired
    private UserService userService;

    /**
     * 查询User列表
     */
    @GetMapping("/list")
    @Operation(summary = "获取学生信息表列表")
    public WebResponse<List<User>> findAll(){

        return WebResponse.success(userService.findAll());
        }



    /**
     * 获取User详细信息
     */
    @GetMapping("/{id}")
    @Operation(summary = "获取学生信息表详细信息")
    public WebResponse<User> findOne(@PathVariable Long id){
        return WebResponse.success(userService.findOne(id));
        }

    /**
     * 新增User
     */
    @PostMapping("/add")
    @Operation(summary = "新增学生信息表")
    public WebResponse<Boolean> save(@RequestBody User user){
        return WebResponse.success(userService.add(user));
        }


/**
     * 修改User
     */
    @PostMapping("/update")
    @Operation(summary = "修改学生信息表")
    public boolean edit(@RequestBody User user){
        return userService.update(user);
    }

    /**
     * 删除User
     */
	@GetMapping("del/{id}")
    @Operation(summary = "删除学生信息表")
    public boolean remove(@PathVariable Long id){
        return userService.deleteByid(id);
    }
}
